home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld: Complete Mac Interactive
/
Macworld Complete Mac Interactive CD)(1994).iso
/
The Best of BMUG
/
Utilities
/
Text and Speech
/
Alpha.5.76
/
Tcl
/
SystemCode
/
latex.tcl
< prev
next >
Wrap
Text File
|
1994-03-16
|
56KB
|
2,547 lines
#############################################################################
#
# latex.tcl: macros and bindings for LaTeX users
#
# -- see files 'LaTeX Help' and 'commands.tex' in the Help folder
#
#############################################################################
#
# version 1.1 and 1.2 (11/10/92) by Richard T. Austin (austin@eecs.umich.edu)
# version 2.0 (1/24/93) by Tom Scavo (scavo@cie.uoregon.edu)
#
# If you make improvements to this file, please share them!
#
#############################################################################
source "$HOME:Tcl:UserCode:smart.tcl"
#############################################################################
#
# Flags and Variables.
#
#############################################################################
set true 1
set false 0
# set insertLatexParameter $true
# set noInsertLatexParameter $false
initTclFlag useBoxMacro
initTclFlag deleteObjectNoisily
initTclFlag deleteEnvironmentNoisily
set useBoxMacro $true
set deleteObjectNoisily $false
set deleteEnvironmentNoisily $true
initTclVar boxMacroName
set boxMacroName "BoxedEPSF"
#############################################################################
#
# Utility Macros.
#
#############################################################################
# A boolean function which checks to see if there's a current selection.
proc isSelection {} {
return [string length [getSelect]]
}
# Select the line containing the insertion point.
proc lineSelect {} {
goto [lineStart [getPos]]
nextLineSelect
}
# A boolean function which takes any string and tests to see if
# that string contains all whitespace characters. Carriage returns
# are considered whitespace, as are spaces and tabs.
proc isWhitespace {anyString} {
set len [string length $anyString]
for {set i 0} {$i < $len} {incr i} {
set c [string index $anyString $i]
if {($c != "\ ") && ($c != "\t") && ($c != "\r")} then {return 0}
}
return 1
}
# Insert a carriage return at the insertion point if any
# character preceding the insertion point (on the same line)
# is a non-whitespace character.
proc openingCarriageReturn {} {
set end [getPos]
set start [lineStart $end]
set text [getText $start $end]
if {![isWhitespace $text]} carriageReturn
}
# Insert a carriage return at the insertion point if any
# character following the insertion point (on the same line)
# is a non-whitespace character.
proc closingCarriageReturn {} {
set start [getPos]
set end [nextLineStart $start]
set text [getText $start $end]
if {![isWhitespace $text]} carriageReturn
}
# Set up tab stop mechanism.
proc gotoTabStop {directionIndicator} {
set searchResult [search -n -f $directionIndicator -m 0 -i 1 -r 0 {•} [getPos]]
if {[llength $searchResult] == 0} then {
message "tab stop not found"
return 0
} else {
goto [lindex $searchResult 0]
return 1
}
}
proc nextTabStop {} {
if {[gotoTabStop 1]} {deleteChar}
}
proc previousTabStop {} {
if {[gotoTabStop 0]} {deleteChar}
}
# Insert an object at the insertion point. If there is a selection and the
# global variable deleteObjectNoisily is false, quietly delete the selection
# first (just like "paste"). Otherwise, prompt the user for the appropriate
# action. Returns true if the object is ultimately inserted, and false if the
# user cancels the operation.
proc insertObject {objectName} {
global deleteObjectNoisily
if {[isSelection]} then {
if {$deleteObjectNoisily} then {
case [askyesno "Delete selection?"] in {
"yes" {deleteText [getPos] [selEnd]}
"no" {backwardChar}
"cancel" {return 0}
}
} else {
deleteText [getPos] [selEnd]
}
}
insertText $objectName
return 1
}
# Insert an object at the insertion point. If there is a selection, wrap
# it inside the parameters $left and $right. Returns true if there is a
# selection (in which case it will wrap), and false otherwise.
proc wrapObject {left right} {
set currentPos [getPos]
set selected [isSelection]
if {$selected} then {
replaceText $currentPos [selEnd] $left [getSelect] $right
} else {
insertText $left "•" $right
}
goto $currentPos
nextTabStop
return $selected
}
# Inserts an environment with the specified name at the insertion point.
# Preserves indentation, and positions the cursor at the beginning of the
# environment body (to be inserted by the calling procedure). If the
# parameter latexParameter is true, a LaTeX parameter is inserted and the
# cursor is positioned there instead. Deletes the current selection quietly
# if the global variable deleteEnvironmentNoisily is false; otherwise the
# user is prompted for directions. Returns true if the environment is
# ultimately inserted, and false if the user cancels the operation.
proc insertEnvironment {environmentName latexParameter} {
global deleteEnvironmentNoisily
if {[isSelection]} then {
if {$deleteEnvironmentNoisily} then {
case [askyesno "Delete selection?"] in {
"yes" {deleteText [getPos] [selEnd]}
"no" {backwardChar}
"cancel" {return 0}
}
} else {
deleteText [getPos] [selEnd]
}
}
set currentPos [getPos]
openingCarriageReturn
insertText "\\begin{" $environmentName "}"
# insert optional LaTeX parameter here:
if {$latexParameter} {insertText "{•}"}
carriageReturn
tab
insertText "•"
carriageReturn
backwardChar
deleteChar
insertText "\\end{" $environmentName "}•"
closingCarriageReturn
goto $currentPos
nextTabStop
return 1
}
# Insert an environment with the given name at the insertion point. If there
# is currently a selection, cut and paste it into the body of the new
# environment, indent it, and leave it highlighted. Returns true if there is
# a selection, and false otherwise.
proc wrapEnvironment {environmentName latexParameter} {
if {[isSelection]} then {
set indent [indentString [getPos]]
set text [getSelect]
deleteText [getPos] [selEnd]
insertText $indent "\r"
backwardChar
insertEnvironment $environmentName $latexParameter
if {$latexParameter} then {
insertText "•"
nextTabStop
}
lineSelect
clear
insertText $text
markHilite
shiftRight
return 1
} else {
insertEnvironment $environmentName $latexParameter
return 0
}
}
#############################################################################
#
# Paragraph Mode Macros.
#
#############################################################################
# Documents:
proc insertDocument {documentType} {
set currentPos [getPos]
insertText "\\documentstyle\[•\]{$documentType}"
carriageReturn
insertEnvironment "document" 0
backwardChar
deleteChar
carriageReturn
insertText "•"
carriageReturn
nextTabStop
carriageReturn
goto $currentPos
nextTabStop
}
proc isDocumentSelected {} {
return 1
}
proc isEmptyFile {} {
return 1
}
proc wrapDocument {documentType} {
if {[isSelection]} then {
if {[isDocumentSelected]} then {
set text [getSelect]
deleteText [getPos] [selEnd]
} else {
case [askyesno "Select entire document?"] in {
"yes" {}
"no" {
set text [getSelect]
deleteText [getPos] [selEnd]
}
"cancel" {return 0}
}
}
set currentPos [getPos]
insertDocument $documentType
insertText "•"
nextTabStop
lineSelect
clear
insertText $text
markHilite
nextTabStop
} else {
if {![isEmptyFile]} then {
case [askyesno "Wrap existing text?"] in {
"yes" {}
"no" {}
"cancel" {return 0}
}
}
insertDocument $documentType
}
return 1
}
proc letter {} {
wrapDocument "letter"
message "type style option(s)"
}
proc article {} {
wrapDocument "article"
message "type style option(s)"
}
proc report {} {
wrapDocument "report"
message "type style option(s)"
}
proc book {} {
wrapDocument "book"
message "type style option(s)"
}
proc custom {} {
catch {prompt "What document type?" "article"} documentType
if {$documentType != "cancel"} then {
wrapDocument $documentType
message "type style option(s)"
}
}
# Sectioning:
proc part {} {
if {[wrapObject "\\part{" "}•"]} then {
message "don't forget label"
} else {
message "type part name"
}
}
proc chapter {} {
if {[wrapObject "\\chapter{" "}•"]} then {
message "don't forget label"
} else {
message "type part name"
}
}
proc section {} {
if {[wrapObject "\\section{" "}•"]} then {
message "don't forget label"
} else {
message "type part name"
}
}
proc subsection {} {
if {[wrapObject "\\subsection{" "}•"]} then {
message "don't forget label"
} else {
message "type part name"
}
}
proc subsubsection {} {
if {[wrapObject "\\subsubsection{" "}•"]} then {
message "don't forget label"
} else {
message "type part name"
}
}
proc paragraph {} {
if {[wrapObject "\\paragraph{" "}•"]} then {
message "don't forget label"
} else {
message "type part name"
}
}
proc subparagraph {} {
if {[wrapObject "\\subparagraph{" "}•"]} then {
message "don't forget label"
} else {
message "type part name"
}
}
# Definitions:
proc myList {} {alertnote "Not yet implemented."}
proc newcommand {} {alertnote "Not yet implemented."}
proc newenvironment {} {alertnote "Not yet implemented."}
proc newtheorem {} {alertnote "Not yet implemented."}
proc renewcommand {} {alertnote "Not yet implemented."}
proc renewenvironment {} {alertnote "Not yet implemented."}
# Text Style:
proc roman {} {
if {[wrapObject "{\\rm " "}•"]} then {
message "roman text set"
} else {
message "enter roman text"
}
}
proc bold {} {
if {[wrapObject "{\\bf " "}•"]} then {
message "bold text set"
} else {
message "enter bold text"
}
}
proc italic {} {
if {[wrapObject "{\\it " "\\/}•"]} then {
insertText "•"
backwardChar
backwardChar
}
message "italic correction?"
}
proc emphatic {} {
if {[wrapObject "{\\em " "\\/}•"]} then {
insertText "•"
backwardChar
backwardChar
}
message "emphatic correction?"
}
proc slanted {} {
if {[wrapObject "{\\sl " "\\/}•"]} then {
insertText "•"
backwardChar
backwardChar
}
message "italic correction?"
}
proc sansSerif {} {
if {[wrapObject "{\\sf " "}•"]} then {
message "sans serif text set"
} else {
message "enter sans serif text"
}
}
proc smallCaps {} {
if {[wrapObject "{\\sc " "}•"]} then {
message "small caps text set"
} else {
message "enter small caps text"
}
}
proc typewriter {} {
if {[wrapObject "{\\tt " "}•"]} then {
message "typewriter text set"
} else {
message "enter typewriter text"
}
}
# Text Size:
proc tiny {} {
if {[wrapObject "{\\tiny " "}•"]} then {
message "tiny text set"
} else {
message "enter tiny text"
}
}
proc smallest {} {
if {[wrapObject "{\\scriptsize " "}•"]} then {
message "scriptsize text set"
} else {
message "enter scriptsize text"
}
}
proc smaller {} {
if {[wrapObject "{\\footnotesize " "}•"]} then {
message "footnotesize text set"
} else {
message "enter footnotesize text"
}
}
proc small {} {
if {[wrapObject "{\\small " "}•"]} then {
message "small text set"
} else {
message "enter small text"
}
}
proc normal {} {
if {[wrapObject "{\\normalsize " "}•"]} then {
message "normalsize text set"
} else {
message "enter normalsize text"
}
}
proc large {} {
if {[wrapObject "{\\large " "}•"]} then {
message "large text set"
} else {
message "enter large text"
}
}
proc larger {} {
if {[wrapObject "{\\Large " "}•"]} then {
message "Large text set"
} else {
message "enter Large text"
}
}
proc largest {} {
if {[wrapObject "{\\LARGE " "}•"]} then {
message "LARGE text set"
} else {
message "enter LARGE text"
}
}
proc huge {} {
if {[wrapObject "{\\huge " "}•"]} then {
message "huge text set"
} else {
message "enter huge text"
}
}
proc gigantic {} {
if {[wrapObject "{\\Huge " "}•"]} then {
message "Huge text set"
} else {
message "enter Huge text"
}
}
# International: not yet implemented.
# Environments:
proc enumerate {} {
catch {prompt "enumerate: how many items?" 3} numberItems
if {$numberItems != "cancel"} then {
set currentPos [getPos]
if {[insertEnvironment "enumerate" 0]} then {
item
insertText " •"
for {set i 1} {$i < $numberItems} {incr i} {
carriageReturn
carriageReturn
item
insertText " •"
}
goto $currentPos
nextTabStop
message "Type first item"
}
}
}
proc itemize {} {
catch {prompt "itemize: how many items?" 3} numberItems
if {$numberItems != "cancel"} then {
set currentPos [getPos]
if {[insertEnvironment "itemize" 0]} then {
item
insertText " •"
for {set i 1} {$i < $numberItems} {incr i} {
carriageReturn
carriageReturn
item
insertText " •"
}
goto $currentPos
nextTabStop
message "Type first item"
}
}
}
proc description {} {
catch {prompt "description: how many items?" 3} numberItems
if {$numberItems != "cancel"} then {
set currentPos [getPos]
if {[insertEnvironment "description" 0]} then {
item
insertText "\[•\] •"
for {set i 1} {$i < $numberItems} {incr i} {
carriageReturn
carriageReturn
item
insertText "\[•\] •"
}
goto $currentPos
nextTabStop
message "Type first item"
}
}
}
proc insertRow {jmax} {
insertText "•"
for {set j 1} {$j < $jmax} {incr j} {
insertText " & •"
}
}
proc tabular {} {
catch {prompt "tabular: how many rows?" 3} numberRows
if {$numberRows != "cancel"} then {
catch {prompt "tabular: how many columns?" 3} numberCols
if {$numberCols != "cancel"} then {
if {[insertEnvironment "tabular" 1]} then {
set beginArgument [getPos]
insertText "|"
for {set j 1} {$j <= $numberCols} {incr j} {
insertText "c|"
}
set endArgument [getPos]
nextTabStop
insertText "\\hline"
for {set i 1} {$i <= $numberRows} {incr i} {
carriageReturn
insertRow $numberCols
insertText " \\\\"
carriageReturn
insertText "\\hline"
}
goto $beginArgument
setMark
goto $endArgument
markHilite
message "modify argument?"
}
}
}
}
proc tabbing {} {alertnote "Not yet implemented."}
proc figure {} {
global useBoxMacro
global boxMacroName
if {$useBoxMacro} then {
set currentPos [getPos]
if {[insertEnvironment "figure" 0]} then {
insertText "\\centerline{\\$boxMacroName{•}}"
} else {
return
}
} else {
if {[wrapEnvironment "figure" 0]} then {
forwardChar
backwardChar
set currentPos [getPos]
} else {
set currentPos [getPos]
insertText "•"
}
}
carriageReturn
insertText "\\caption{•}"
carriageReturn
insertText "\\protect\\label{•}"
goto $currentPos
nextTabStop
}
proc table {} {
if {[wrapEnvironment "table" 0]} then {
forwardChar
backwardChar
set currentPos [getPos]
} else {
set currentPos [getPos]
insertText "•"
}
carriageReturn
insertText "\\caption{•}"
carriageReturn
insertText "\\protect\\label{•}"
goto $currentPos
nextTabStop
}
proc slide {} {
wrapEnvironment "slide" 1
message "enter colors"
}
proc verbatim {} {wrapEnvironment "verbatim" 0}
proc quote {} {wrapEnvironment "quote" 0}
proc quotation {} {wrapEnvironment "quotation" 0}
proc verse {} {wrapEnvironment "verse" 0}
proc index {} {alertnote "Not yet implemented."}
proc bibliography {} {
catch {prompt "bibliography: how many bibitems?" 3} numberItems
if {$numberItems != "cancel"} then {
if {[insertEnvironment "thebibliography" 1]} then {
set beginArgument [getPos]
insertText "99"
set endArgument [getPos]
nextTabStop
insertText "\\bibitem{•}"
carriageReturn
insertText "•"
for {set i 1} {$i < $numberItems} {incr i} {
carriageReturn
carriageReturn
insertText "\\bibitem{•}"
carriageReturn
insertText "•"
}
goto $beginArgument
setMark
goto $endArgument
markHilite
message "modify argument?"
}
}
}
proc general {} {
catch {prompt "What environment?" "center"} environmentName
if {$environmentName != "cancel"} {wrapEnvironment $environmentName 0}
}
# Boxes:
proc mbox {} {
if {[wrapObject "\\mbox{" "}•"]} then {
message "mbox set"
} else {
message "enter text"
}
}
proc fbox {} {alertnote "Not yet implemented."}
proc parbox {} {alertnote "Not yet implemented."}
# Misc:
proc ellipsis {} {insertObject "\\ldots"}
proc sectionMark {} {insertObject "\\S"}
proc paragraphMark {} {insertObject "\\P"}
proc dagger {} {insertObject "\\dag"}
proc dblDagger {} {insertObject "\\ddag"}
proc copyright {} {insertObject "\\copyright"}
proc pounds {} {insertObject "\\pounds"}
proc {en-dash} {} {insertObject "--"}
proc {em-dash} {} {insertObject "---"}
proc texLogo {} {insertObject "\\TeX"}
proc latexLogo {} {insertObject "\\LaTeX"}
proc today {} {insertObject "\\today"}
proc quotes {} {
if {[wrapObject "`" "'•"]} then {
message "text quoted"
} else {
message "enter text"
}
}
proc dblQuotes {} {
if {[wrapObject "``" "''•"]} then {
message "text double quoted"
} else {
message "enter text"
}
}
proc note {} {
if {[wrapObject "\\marginpar{" "}•"]} then {
message "marginal note set"
} else {
message "enter marginal note"
}
}
proc footnote {} {
if {[wrapObject "\\footnote{" "}•"]} then {
message "footnote set"
} else {
message "enter footnote"
}
}
proc label {} {
if {[wrapObject "\\label{" "}•"]} then {
message "label defined"
} else {
message "enter label"
}
}
proc crossRef {} {
if {[wrapObject "\\ref{" "}•"]} then {
message "cross-reference made"
} else {
message "enter cross-reference"
}
}
proc pageRef {} {
if {[wrapObject "\\pageref{" "}•"]} then {
message "page reference made"
} else {
message "enter page reference"
}
}
proc citation {} {
if {[wrapObject "\\cite{" "}•"]} then {
message "citation made"
} else {
message "enter citation"
}
}
proc item {} {insertObject "\\item"}
proc bibitem {} {
if {[wrapObject "\\bibitem{" "}•"]} then {
message "bibitem set"
} else {
message "enter bibitem"
}
}
#############################################################################
#
# Math Mode Macros.
#
#############################################################################
# Modes:
proc texMath {} {
if {[wrapObject "$" "$•"]} then {
message "formula set"
} else {
message "enter formula"
}
}
proc texDisplaymath {} {
if {[wrapObject "$$" "$$•"]} then {
message "displayed formula set"
} else {
message "enter displayed formula"
}
}
proc latexMath {} {
if {[wrapObject "\\( " " \\)•"]} then {
message "formula set"
} else {
message "enter formula"
}
}
proc latexDisplaymath {} {
if {[wrapObject "\\\[ " " \\\]•"]} then {
message "displayed formula set"
} else {
message "enter displayed formula"
}
}
# Environments:
proc math {} {wrapEnvironment "math" 0}
proc displaymath {} {wrapEnvironment "displaymath" 0}
proc equation {} {
if {[wrapEnvironment "equation" 0]} then {
forwardChar
backwardChar
set currentPos [getPos]
} else {
set currentPos [getPos]
insertText "•"
}
carriageReturn
insertText "\\label{•}"
goto $currentPos
nextTabStop
}
proc myArray {} {
catch {prompt "array: how many rows?" 3} numberRows
if {$numberRows != "cancel"} then {
catch {prompt "array: how many columns?" 3} numberCols
if {$numberCols != "cancel"} then {
if {[insertEnvironment "array" 1]} then {
set beginArgument [getPos]
for {set j 1} {$j <= $numberCols} {incr j} {
insertText "c"
}
set endArgument [getPos]
nextTabStop
for {set i 1} {$i < $numberRows} {incr i} {
insertRow $numberCols
insertText " \\\\"
carriageReturn
}
insertRow $numberCols
goto $beginArgument
setMark
goto $endArgument
markHilite
message "modify argument?"
}
}
}
}
proc eqnarray {} {
catch {prompt "eqnarray: how many rows?" 3} numberRows
if {$numberRows != "cancel"} then {
set currentPos [getPos]
if {[insertEnvironment "eqnarray" 0]} then {
for {set i 1} {$i < $numberRows} {incr i} {
insertRow 3
carriageReturn
insertText "\\label{•} \\\\"
carriageReturn
}
insertRow 3
carriageReturn
insertText "\\label{•}"
goto $currentPos
nextTabStop
}
}
}
proc eqnarrayStar {} {
catch {prompt "eqnarray*: how many rows?" 3} numberRows
if {$numberRows != "cancel"} then {
set currentPos [getPos]
if {[insertEnvironment "eqnarray*" 0]} then {
for {set i 1} {$i < $numberRows} {incr i} {
insertRow 3
insertText " \\\\"
carriageReturn
}
insertRow 3
goto $currentPos
nextTabStop
}
}
}
# Formulas:
proc subscript {} {
if {[wrapObject "_{" "}•"]} then {
message "subscript set"
} else {
message "enter subscript"
}
}
proc superscript {} {
if {[wrapObject "^{" "}•"]} then {
message "superscript set"
} else {
message "enter superscript"
}
}
proc fraction {} {
set currentPos [getPos]
if {[isSelection]} then {
set selection [getSelect]
set args [split $selection /]
set len [llength $args]
deleteText $currentPos [selEnd]
if {$len == 1} then {
# maybe the selection should be deleted in this case?
insertText "\\frac{" $selection "}{•}•"
goto $currentPos
nextTabStop
message "enter denominator"
} else {
set firstArg [lindex $args 0]
set restArgs [lrange $args 1 [expr $len-1]]
insertText "\\frac{" $firstArg "}{" [join $restArgs /] "}"
if {$len > 2} {message "beware of multiple /"}
}
} else {
insertText "\\frac{•}{•}•"
goto $currentPos
nextTabStop
message "enter numerator"
}
}
proc squareRoot {} {
if {[wrapObject "\\sqrt{" "}•"]} then {
message "square root set"
} else {
message "enter formula"
}
}
proc nthRoot {} {
if {[wrapObject "\\sqrt\[•\]{" "}•"]} then {
message "enter root"
} else {
message "enter root, then formula"
}
}
proc oneParameter {} {
catch {prompt "Command name?" "sqrt"} commandName
if {$commandName != "cancel"} {wrapObject "\\$commandName{" "}•"}
}
proc twoParameters {} {
catch {prompt "Command name?" "frac"} commandName
if {$commandName != "cancel"} then {
set currentPos [getPos]
if {[insertObject "\\$commandName{•}{•}•"]} then {
goto $currentPos
nextTabStop
}
}
}
# Greek:
proc alpha {} {insertObject "\\alpha"}
proc beta {} {insertObject "\\beta"}
proc gamma {} {insertObject "\\gamma"}
proc delta {} {insertObject "\\delta"}
proc epsilon {} {insertObject "\\epsilon"}
proc zeta {} {insertObject "\\zeta"}
proc eta {} {insertObject "\\eta"}
proc theta {} {insertObject "\\theta"}
proc iota {} {insertObject "\\iota"}
proc kappa {} {insertObject "\\kappa"}
proc lambda {} {insertObject "\\lambda"}
proc mu {} {insertObject "\\mu"}
proc nu {} {insertObject "\\nu"}
proc xi {} {insertObject "\\xi"}
proc pi {} {insertObject "\\pi"}
proc rho {} {insertObject "\\rho"}
proc sigma {} {insertObject "\\sigma"}
proc tau {} {insertObject "\\tau"}
proc upsilon {} {insertObject "\\upsilon"}
proc phi {} {insertObject "\\phi"}
proc chi {} {insertObject "\\chi"}
proc psi {} {insertObject "\\psi"}
proc omega {} {insertObject "\\omega"}
proc capGamma {} {insertObject "\\Gamma"}
proc capDelta {} {insertObject "\\Delta"}
proc capTheta {} {insertObject "\\Theta"}
proc capLambda {} {insertObject "\\Lambda"}
proc capXi {} {insertObject "\\Xi"}
proc capPi {} {insertObject "\\Pi"}
proc capSigma {} {insertObject "\\Sigma"}
proc capUpsilon {} {insertObject "\\Upsilon"}
proc capPhi {} {insertObject "\\Phi"}
proc capPsi {} {insertObject "\\Psi"}
proc capOmega {} {insertObject "\\Omega"}
proc varEpsilon {} {insertObject "\\varepsilon"}
proc varTheta {} {insertObject "\\vartheta"}
proc varPi {} {insertObject "\\varpi"}
proc varRho {} {insertObject "\\varrho"}
proc varSigma {} {insertObject "\\varsigma"}
proc varPhi {} {insertObject "\\varphi"}
# Binary Ops:
proc plusOrMinus {} {insertObject "\\pm"}
proc minusOrPlus {} {insertObject "\\mp"}
proc multiply {} {insertObject "\\times"}
proc divide {} {insertObject "\\div"}
proc asterisk {} {insertObject "\\ast"}
proc star {} {insertObject "\\star"}
proc circle {} {insertObject "\\circ"}
proc bigCircle {} {insertObject "\\bigcirc"}
proc bullet {} {insertObject "\\bullet"}
proc centerDot {} {insertObject "\\cdot"}
proc intersection {} {insertObject "\\cap"}
proc union {} {insertObject "\\cup"}
proc logicalAnd {} {insertObject "\\wedge"}
proc logicalOr {} {insertObject "\\vee"}
proc setMinus {} {insertObject "\\setminus"}
# Relations:
proc notEqual {} {insertObject "\\neq"}
proc lessOrEqual {} {insertObject "\\leq"}
proc greaterOrEqual {} {insertObject "\\geq"}
proc subset {} {insertObject "\\subset"}
proc superset {} {insertObject "\\supset"}
proc subsetOrEqual {} {insertObject "\\subseteq"}
proc supersetOrEqual {} {insertObject "\\supseteq"}
proc elementOf {} {insertObject "\\in"}
proc equivalent {} {insertObject "\\equiv"}
proc similar {} {insertObject "\\sim"}
proc similarEqual {} {insertObject "\\simeq"}
proc dotEqual {} {insertObject "\\doteq"}
proc approximate {} {insertObject "\\approx"}
proc congruent {} {insertObject "\\cong"}
# Large Ops:
proc insertLargeOp {commandName} {
set currentPos [getPos]
insertText "\\$commandName"
insertText "_{•}^{•}•"
goto $currentPos
nextTabStop
}
proc sum {} {insertLargeOp "sum"}
proc product {} {insertLargeOp "prod"}
proc integral {} {insertLargeOp "int"}
proc bigUnion {} {insertLargeOp "bigcup"}
proc bigIntersection {} {insertLargeOp "bigcap"}
proc bigAnd {} {insertLargeOp "bigwedge"}
proc bigOr {} {insertLargeOp "bigvee"}
# Arrows:
proc mapsTo {} {insertObject "\\mapsto"}
proc leftArrow {} {insertObject "\\leftarrow"}
proc rightArrow {} {insertObject "\\rightarrow"}
proc {left-rightArrow} {} {insertObject "\\leftrightarrow"}
proc dblLeftArrow {} {insertObject "\\Leftarrow"}
proc dblRightArrow {} {insertObject "\\Rightarrow"}
proc {dblLeft-rightArrow} {} {insertObject "\\Leftrightarrow"}
# Dots:
proc centerDots {} {insertObject "\\cdots"}
proc verticalDots {} {insertObject "\\vdots"}
proc diagonalDots {} {insertObject "\\ddots"}
# Symbols:
proc aleph {} {insertObject "\\aleph"}
proc emptySet {} {insertObject "\\emptyset"}
proc negation {} {insertObject "\\neg"}
proc forAll {} {insertObject "\\forall"}
proc exists {} {insertObject "\\exists"}
proc scriptL {} {insertObject "\\ell"}
proc nabla {} {insertObject "\\nabla"}
proc partial {} {insertObject "\\partial"}
proc infinity {} {insertObject "\\infty"}
proc backslash {} {insertObject "\\backslash"}
proc angle {} {insertObject "\\angle"}
proc box {} {insertObject "\\Box"}
proc diamond {} {insertObject "\\Diamond"}
proc triangle {} {insertObject "\\triangle"}
# Functions: not yet implemented.
# Delimiters:
proc parentheses {} {
if {[wrapObject "(" ")•"]} then {
message "formula delimited"
} else {
message "enter formula"
}
}
proc brackets {} {
if {[wrapObject "\[" "\]•"]} then {
message "formula delimited"
} else {
message "enter formula"
}
}
proc braces {} {
if {[wrapObject "\\\{" "\\\}•"]} then {
message "formula delimited"
} else {
message "enter formula"
}
}
proc absoluteValue {} {
if {[wrapObject "|" "|•"]} then {
message "formula delimited"
} else {
message "enter formula"
}
}
proc otherDelims {} {
catch {prompt "Choose delimiters:" "parentheses" "" "parentheses" "brackets" "braces" "angle brackets" "vertical bars" "double bars" "ceiling" "floor"} delimType
if {$delimType != "cancel"} then {
case $delimType in {
"parentheses" {
set leftDelim "("
set rightDelim ")"
}
"brackets" {
set leftDelim "\["
set rightDelim "\]"
}
"braces" {
set leftDelim "\\\{"
set rightDelim "\\\}"
}
"{angle brackets}" {
set leftDelim "\\langle"
set rightDelim "\\rangle"
}
"{vertical bars}" {
set leftDelim "|"
set rightDelim "|"
}
"{double bars}" {
set leftDelim "\\|"
set rightDelim "\\|"
}
"ceiling" {
set leftDelim "\\lceil"
set rightDelim "\\rceil"
}
"floor" {
set leftDelim "\\lfloor"
set rightDelim "\\rfloor"
}
default {
alertnote "\"$delimType\" not recognized"
return
}
}
if {[wrapObject "$leftDelim" "$rightDelim•"]} then {
message "formula delimited"
} else {
message "enter formula"
}
}
}
proc {half-openInterval} {} {
if {[wrapObject "(" "\]•"]} then {
message "formula delimited"
} else {
message "enter formula"
}
}
proc {half-closedInterval} {} {
if {[wrapObject "\[" ")•"]} then {
message "formula delimited"
} else {
message "enter formula"
}
}
proc bigParentheses {} {
if {[wrapObject "\\left(" "\\right)•"]} then {
message "formula delimited"
} else {
message "enter formula"
}
}
proc bigBrackets {} {
if {[wrapObject "\\left\[" "\\right\]•"]} then {
message "formula delimited"
} else {
message "enter formula"
}
}
proc bigBraces {} {
if {[wrapObject "\\left\\\{" "\\right\\\}•"]} then {
message "formula delimited"
} else {
message "enter formula"
}
}
proc bigAbsoluteValue {} {
if {[wrapObject "\\left|" "\\right|•"]} then {
message "formula delimited"
} else {
message "enter formula"
}
}
proc otherBigDelims {} {
catch {prompt "Choose delimiters:" "parentheses" "" "parentheses" "brackets" \
"braces" "angle brackets" "vertical bars" "double bars" \
"ceiling" "floor"} delimType
if {$delimType != "cancel"} then {
case $delimType in {
"parentheses" {
set leftDelim "("
set rightDelim ")"
}
"brackets" {
set leftDelim "\["
set rightDelim "\]"
}
"braces" {
set leftDelim "\\\{"
set rightDelim "\\\}"
}
"{angle brackets}" {
set leftDelim "\\langle"
set rightDelim "\\rangle"
}
"{vertical bars}" {
set leftDelim "|"
set rightDelim "|"
}
"{double bars}" {
set leftDelim "\\|"
set rightDelim "\\|"
}
"ceiling" {
set leftDelim "\\lceil"
set rightDelim "\\rceil"
}
"floor" {
set leftDelim "\\lfloor"
set rightDelim "\\rfloor"
}
default {
alertnote "\"$delimType\" not recognized"
return
}
}
if {[wrapObject "\\left$leftDelim" "\\right$rightDelim•"]} then {
message "formula delimited"
} else {
message "enter formula"
}
}
}
proc bigLeftBrace {} {
if {[wrapObject "\\left\\\{" "\\right.•"]} then {
message "formula delimited"
} else {
message "enter formula"
}
}
proc otherMixedBigDelims {} {
catch {prompt "Choose left delimiter:" "parenthesis" "" "parenthesis" "bracket" \
"brace" "angle bracket" "vertical bar" "double bar" "ceiling" "floor" \
"slash" "backslash" "none"} delimType
if {$delimType != "cancel"} then {
case $delimType in {
"parenthesis" {set leftDelim "("}
"bracket" {set leftDelim "\["}
"brace" {set leftDelim "\\\{"}
"{angle bracket}" {set leftDelim "\\langle"}
"{vertical bar}" {set leftDelim "|"}
"{double bar}" {set leftDelim "\\|"}
"ceiling" {set leftDelim "\\lceil"}
"floor" {set leftDelim "\\lfloor"}
"slash" {set leftDelim "/"}
"backslash" {set leftDelim "\\backslash"}
"none" {set leftDelim "."}
default {
alertnote "\"$delimType\" not recognized"
return
}
}
catch {prompt "Choose right delimiter:" "parenthesis" "" "parenthesis" "bracket" \
"brace" "angle bracket" "vertical bar" "double bar" "ceiling" "floor" \
"slash" "backslash" "none"} delimType
if {$delimType != "cancel"} then {
case $delimType in {
"parenthesis" {set rightDelim ")"}
"bracket" {set rightDelim "\]"}
"brace" {set rightDelim "\\\}"}
"{angle bracket}" {set rightDelim "\\rangle"}
"{vertical bar}" {set rightDelim "|"}
"{double bar}" {set rightDelim "\\|"}
"ceiling" {set rightDelim "\\rceil"}
"floor" {set rightDelim "\\rfloor"}
"slash" {set rightDelim "/"}
"backslash" {set rightDelim "\\backslash"}
"none" {set rightDelim "."}
default {
alertnote "\"$delimType\" not recognized"
return
}
}
if {[wrapObject "\\left$leftDelim" "\\right$rightDelim•"]} then {
message "formula delimited"
} else {
message "enter formula"
}
}
}
}
# Accents:
proc hat {} {
if {[isSelection] > 1} then {
beep
alertnote "Warning: only a single character may be accented!"
}
if {[wrapObject "\\hat{" "}•"]} then {
message "accent set"
} else {
message "enter one character"
}
}
proc check {} {
if {[isSelection] > 1} then {
beep
alertnote "Warning: only a single character may be accented!"
}
if {[wrapObject "\\check{" "}•"]} then {
message "accent set"
} else {
message "enter one character"
}
}
proc breve {} {
if {[isSelection] > 1} then {
beep
alertnote "Warning: only a single character may be accented!"
}
if {[wrapObject "\\breve{" "}•"]} then {
message "accent set"
} else {
message "enter one character"
}
}
proc acuteAccent {} {
if {[isSelection] > 1} then {
beep
alertnote "Warning: only a single character may be accented!"
}
if {[wrapObject "\\acute{" "}•"]} then {
message "accent set"
} else {
message "enter one character"
}
}
proc graveAccent {} {
if {[isSelection] > 1} then {
beep
alertnote "Warning: only a single character may be accented!"
}
if {[wrapObject "\\grave{" "}•"]} then {
message "accent set"
} else {
message "enter one character"
}
}
proc tilde {} {
if {[isSelection] > 1} then {
beep
alertnote "Warning: only a single character may be accented!"
}
if {[wrapObject "\\tilde{" "}•"]} then {
message "accent set"
} else {
message "enter one character"
}
}
proc bar {} {
if {[isSelection] > 1} then {
beep
alertnote "Warning: only a single character may be accented!"
}
if {[wrapObject "\\bar{" "}•"]} then {
message "accent set"
} else {
message "enter one character"
}
}
proc vector {} {
if {[isSelection] > 1} then {
beep
alertnote "Warning: only a single character may be accented!"
}
if {[wrapObject "\\vec{" "}•"]} then {
message "accent set"
} else {
message "enter one character"
}
}
proc dot {} {
if {[isSelection] > 1} then {
beep
alertnote "Warning: only a single character may be accented!"
}
if {[wrapObject "\\dot{" "}•"]} then {
message "accent set"
} else {
message "enter one character"
}
}
proc dblDot {} {
if {[isSelection] > 1} then {
beep
alertnote "Warning: only a single character may be accented!"
}
if {[wrapObject "\\ddot{" "}•"]} then {
message "accent set"
} else {
message "enter one character"
}
}
proc wideHat {} {
if {[isSelection] > 3} then {
beep
alertnote "Warning: only a few characters may be accented!"
}
if {[wrapObject "\\widehat{" "}•"]} then {
message "accent set"
} else {
message "enter a few characters"
}
}
proc wideTilde {} {
if {[isSelection] > 3} then {
beep
alertnote "Warning: only a few characters may be accented!"
}
if {[wrapObject "\\widetilde{" "}•"]} then {
message "accent set"
} else {
message "enter a few characters"
}
}
proc dotlessI {} {insertObject "\\imath"}
proc dotlessJ {} {insertObject "\\jmath"}
# Grouping:
proc underline {} {
if {[wrapObject "\\underline{" "}•"]} then {
message "selection underlined"
} else {
message "enter text"
}
}
proc overline {} {
if {[wrapObject "\\overline{" "}•"]} then {
message "selection overlined"
} else {
message "enter text"
}
}
proc underbrace {} {
if {[wrapObject "\\underbrace{" "}•"]} then {
message "selection underbraced"
} else {
message "enter text"
}
}
proc overbrace {} {
if {[wrapObject "\\overbrace{" "}•"]} then {
message "selection overbraced"
} else {
message "enter text"
}
}
proc stack {} {
set currentPos [getPos]
if {[insertObject "\\stackrel{•}{•}•"]} then {
goto $currentPos
nextTabStop
message "1st arg scriptstyle"
}
}
# Spacing:
proc thin {} {insertObject "\\,"}
proc negThin {} {insertObject "\\!"}
proc medium {} {insertObject "\\:"}
proc thick {} {insertObject "\\;"}
proc quad {} {insertObject "\\quad"}
proc dblQuad {} {insertObject "\\qquad"}
# Math Style:
proc mathItalic {} {
if {[wrapObject "{\\mit " "}•"]} then {
message "math italics set"
} else {
message "enter italicized text"
}
}
proc calligraphic {} {
# Check for upper-case arguments only:
if {[wrapObject "{\\cal " "}•"]} then {
message "calligraphics set"
} else {
message "enter text"
}
}
proc fraktur {} {
alertnote "Not yet implemented."
}
proc script {} {
alertnote "Not yet implemented."
}
proc blackboardBold {} {
alertnote "Not yet implemented."
}
proc displayStyle {} {
if {[wrapObject "{\\displaystyle " "}•"]} then {
message "displaystyle set"
} else {
message "enter displaystyle text"
}
}
proc textStyle {} {
if {[wrapObject "{\\textstyle " "}•"]} then {
message "textstyle set"
} else {
message "enter textstyle text"
}
}
proc scriptStyle {} {
if {[wrapObject "{\\scriptstyle " "}•"]} then {
message "scriptstyle set"
} else {
message "enter scriptstyle text"
}
}
proc scriptscriptStyle {} {
if {[wrapObject "{\\scriptscriptstyle " "}•"]} then {
message "scriptscriptstyle set"
} else {
message "enter scriptscriptstyle text"
}
}
#############################################################################
#
# LaTeX Menu Definition.
#
#############################################################################
proc interpretMenuItem {menu item} {
switch $item {
"list" {set func "myList"}
"array" {set func "myArray"}
"eqnarray\*" {set func "eqnarrayStar"}
default {set func $item}
}
eval $func
}
# LaTeX mode
proc setTexMode {} {
global latexMenu
changeMode "TeX"
uplevel #0 {
set wordBreakPreface {[^a-zA-Z0-9]}
set wordBreak {[a-zA-Z0-9]+}
set elecLBrace 0
set elecRBrace 0
set electricSemi 0
set wordWrap 1
set prefixString "% "
set suffixString { \\\\}
set sortedIsDefault 0
set funcExpr {^\\(sub)*section\*?{([^{}]*)}}
# set funcExpr {^\\(sub)*section\*?{(.*)}$}
set funcPar 2
set savedIsMeta $optionIsMeta
# Uncomment next line to use option key in Tex bindings.
# set optionIsMeta 0
# Next is a call to a random proc in the latex file to make sure
# is it auto-loaded.
isSelection
insertMenu $latexMenu
}
}
#================================================================================
set latexMenu "•266"
proc latex {} {
global latexPath
set sig ""
catch {string trim [lindex [getfinfo $latexPath] 1] '} sig
set name [checkRunning latex $sig latexPath]
if {![string length $name]} return
switchTo $name
}
proc commentLine {} {
beginningOfLine
insertText "% "
nextLine
beginningOfLine
}
# Open file in same directory, expect name w/o extension selected.
proc openInputFile {} {
set text [getSelect].tex
if {[string length $text] < 5} { beep; return }
foreach f [winNames] {
if {$f == $text} {
bringToFront $f
return
}
}
edit [file dirname [lindex [winNames -f] 0]]:$text
}
menu -n $latexMenu {
"/-latex"
"openInputFile"
"(-"
{menu -n Documents -p interpretMenuItem {
"letter"
"article"
"report"
"book"
"(-"
"custom…"}
}
{menu -n Sectioning -p interpretMenuItem {
"part"
"chapter"
"section"
"subsection"
"subsubsection"
"paragraph"
"subparagraph"}
}
{menu -n (Definitions -p interpretMenuItem {
"list…"
"(-"
"newcommand…"
"newenvironment…"
"newtheorem…"
"(-"
"renewcommand…"
"renewenvironment…"}
}
"(-"
{menu -n TextStyle -p interpretMenuItem {
"roman"
"bold"
"italic"
"emphatic"
"slanted"
"sansSerif"
"smallCaps"
"typewriter"}
}
{menu -n TextSize -p interpretMenuItem {
"tiny"
"smallest"
"smaller"
"small"
"normal"
"large"
"larger"
"largest"
"huge"
"gigantic"}
}
{menu -n (International -p interpretMenuItem {
}
}
{menu -n Environments -p interpretMenuItem {
"enumerate…"
"itemize…"
"description…"
"(-"
"tabular…"
"(tabbing"
"(-"
"figure"
"table"
"slide"
"(-"
"verbatim"
"quote"
"quotation"
"verse"
"(-"
"(index…"
"bibliography…"
"(-"
"general…"}
}
{menu -n Boxes -p interpretMenuItem {
"mbox"
"(fbox"
"(parbox"}
}
{menu -n Miscellaneous -p interpretMenuItem {
"ellipsis"
"sectionMark"
"paragraphMark"
"dagger"
"dblDagger"
"en-dash"
"em-dash"
"texLogo"
"latexLogo"
"copyright"
"pounds"
"today"
"(-"
"quotes"
"dblQuotes"
"(-"
"note"
"footnote"
"(-"
"label"
"crossRef"
"pageRef"
"citation"
"(-"
"item"
"bibitem"
}
}
"(-"
{menu -n mathModes -p interpretMenuItem {
"texMath"
"texDisplaymath"
"(-"
"latexMath"
"latexDisplaymath"}
}
{menu -n mathEnvironments -p interpretMenuItem {
"math"
"displaymath"
"equation"
"(-"
"array…"
"eqnarray…"
"eqnarray*…"
"(-"
"general…"}
}
{menu -n Formulas -p interpretMenuItem {
"subscript"
"superscript"
"fraction"
"squareRoot"
"nthRoot"
"(-"
"oneParameter…"
"twoParameters…"
}
}
{menu -n Greek -p interpretMenuItem {
"alpha"
"beta"
"gamma"
"delta"
"epsilon"
"zeta"
"eta"
"theta"
"iota"
"kappa"
"lambda"
"mu"
"nu"
"xi"
"pi"
"rho"
"sigma"
"tau"
"upsilon"
"phi"
"chi"
"psi"
"omega"
}
}
{menu -n Greek2 -p interpretMenuItem {
"capGamma"
"capDelta"
"capTheta"
"capLambda"
"capXi"
"capPi"
"capSigma"
"capUpsilon"
"capPhi"
"capPsi"
"capOmega"
"(-"
"varEpsilon"
"varTheta"
"varPi"
"varRho"
"varSigma"
"varPhi"
}
}
{menu -n BinaryOperators -p interpretMenuItem {
"plusOrMinus"
"minusOrPlus"
"multiply"
"divide"
"asterisk"
"star"
"centerDot"
"bullet"
"circle"
"bigCircle"
"intersection"
"union"
"logicalAnd"
"logicalOr"
"setMinus"
}
}
{menu -n Relations -p interpretMenuItem {
"notEqual"
"lessOrEqual"
"greaterOrEqual"
"subset"
"superset"
"subsetOrEqual"
"supersetOrEqual"
"elementOf"
"equivalent"
"similar"
"similarEqual"
"dotEqual"
"approximate"
"congruent"
}
}
{menu -n LargeOperators -p interpretMenuItem {
"sum"
"product"
"integral"
"bigUnion"
"bigIntersection"
"bigAnd"
"bigOr"
}
}
{menu -n Arrows -p interpretMenuItem {
"mapsTo"
"leftArrow"
"rightArrow"
"left-rightArrow"
"dblLeftArrow"
"dblRightArrow"
"dblLeft-rightArrow"
}
}
{menu -n Dots -p interpretMenuItem {
"centerDot"
"bullet"
"(-"
"ellipsis"
"centerDots"
"verticalDots"
"diagonalDots"
}
}
{menu -n Symbols -p interpretMenuItem {
"aleph"
"emptySet"
"negation"
"forAll"
"exists"
"scriptL"
"nabla"
"partial"
"infinity"
"backslash"
"angle"
"box"
"diamond"
"triangle"
}
}
{menu -n (Functions -p interpretMenuItem {
}
}
{menu -n Delimiters -p interpretMenuItem {
"parentheses"
"brackets"
"braces"
"absoluteValue"
"otherDelims…"
"(-"
"half-openInterval"
"half-closedInterval"
"(-"
"bigParentheses"
"bigBrackets"
"bigBraces"
"bigAbsoluteValue"
"otherBigDelims…"
"(-"
"bigLeftBrace"
"otherMixedBigDelims…"
}
}
{menu -n mathAccents -p interpretMenuItem {
"hat"
"check"
"breve"
"acuteAccent"
"graveAccent"
"tilde"
"bar"
"vector"
"dot"
"dblDot"
"(-"
"wideHat"
"wideTilde"
"(-"
"dotlessI"
"dotlessJ"
}
}
{menu -n Grouping -p interpretMenuItem {
"underline"
"overline"
"underbrace"
"overbrace"
"(-"
"stack"
}
}
{menu -n Spacing -p interpretMenuItem {
"thin"
"negThin"
"medium"
"thick"
"(-"
"quad"
"dblQuad"
}
}
{menu -n MathStyle -p interpretMenuItem {
"mathItalic"
"calligraphic"
"(-"
"(fraktur"
"(script"
"(blackboardBold"
"(-"
"displayStyle"
"textStyle"
"scriptStyle"
"scriptscriptStyle"
}
}
}
#############################################################################
#
# Special Key Bindings.
#
# abbreviations: <o> = option, <z> = control, <s> = shift, <c> = command
#
#############################################################################
bind 0x14 <z> commentLine TeX
if {$optionIsMeta == "0"} then {
# use option for macros, escape for meta
bind 'a' <o> alpha "TeX"
bind 'a' <os> angle "TeX"
bind 'a' <oz> forAll "TeX"
bind 'a' <co> acuteAccent "TeX"
bind 'b' <o> beta "TeX"
bind 'b' <oz> box "TeX"
bind 'b' <co> bar "TeX"
bind 'b' <cs> bold "TeX"
bind 'c' <o> chi "TeX"
bind 'c' <co> check "TeX"
bind 'c' <cs> citation "TeX"
bind 'c' <cso> calligraphic "TeX"
bind 'd' <o> delta "TeX"
bind 'd' <os> capDelta "TeX"
bind 'd' <oz> diamond "TeX"
bind 'd' <co> dot "TeX"
bind 'd' <cso> dblDot "TeX"
bind 'e' <o> epsilon "TeX"
bind 'e' <os> exists "TeX"
bind 'e' <oz> varEpsilon "TeX"
bind 'e' <cs> emphatic "TeX"
bind 'f' <o> phi "TeX"
bind 'f' <os> capPhi "TeX"
bind 'f' <oz> varPhi "TeX"
bind 'f' <co> fraction "TeX"
bind 'f' <cs> footnote "TeX"
bind 'g' <o> gamma "TeX"
bind 'g' <os> capGamma "TeX"
bind 'g' <oz> copyright "TeX"
bind 'g' <co> graveAccent "TeX"
bind 'h' <o> eta "TeX"
bind 'h' <co> hat "TeX"
bind 'h' <cs> smallCaps "TeX"
bind 'h' <cso> wideHat "TeX"
bind 'i' <o> iota "TeX"
bind 'i' <oz> dotlessI "TeX"
bind 'i' <co> integral "TeX"
bind 'i' <cs> italic "TeX"
bind 'i' <cso> mathItalic "TeX"
bind 'j' <o> partial "TeX"
bind 'j' <oz> dotlessJ "TeX"
bind 'k' <o> kappa "TeX"
bind 'l' <o> lambda "TeX"
bind 'l' <os> capLambda "TeX"
bind 'l' <oz> scriptL "TeX"
bind 'l' <cs> label "TeX"
bind 'm' <o> mu "TeX"
bind 'm' <oz> mapsTo "TeX"
bind 'm' <co> mbox "TeX"
bind 'm' <cs> mbox "TeX"
bind 'n' <o> nu "TeX"
bind 'n' <os> aleph "TeX"
bind 'n' <oz> intersection "TeX"
bind 'n' <co> nthRoot "TeX"
bind 'n' <cs> note "TeX"
bind 'o' <o> circle "TeX"
bind 'o' <os> bigCircle "TeX"
bind 'o' <co> overline "TeX"
bind 'o' <cso> overbrace "TeX"
bind 'p' <o> pi "TeX"
bind 'p' <os> capPi "TeX"
bind 'p' <oz> varPi "TeX"
bind 'p' <co> product "TeX"
bind 'p' <cs> pageRef "TeX"
bind 'q' <o> theta "TeX"
bind 'q' <os> capTheta "TeX"
bind 'q' <oz> varTheta "TeX"
bind 'r' <o> rho "TeX"
bind 'r' <oz> varRho "TeX"
bind 'r' <co> squareRoot "TeX"
bind 'r' <cs> roman "TeX"
bind 's' <o> sigma "TeX"
bind 's' <os> capSigma "TeX"
bind 's' <oz> varSigma "TeX"
bind 's' <co> sum "TeX"
bind 's' <cs> slanted "TeX"
bind 't' <o> tau "TeX"
bind 't' <os> dagger "TeX"
bind 't' <oz> triangle "TeX"
bind 't' <co> tilde "TeX"
bind 't' <cs> typewriter "TeX"
bind 't' <cso> wideTilde "TeX"
bind 'u' <o> upsilon "TeX"
bind 'u' <os> capUpsilon "TeX"
bind 'u' <oz> union "TeX"
bind 'u' <co> underline "TeX"
bind 'u' <cso> underbrace "TeX"
bind 'v' <o> nabla "TeX"
bind 'v' <oz> logicalOr "TeX"
bind 'v' <co> vector "TeX"
bind 'w' <o> omega "TeX"
bind 'w' <os> capOmega "TeX"
bind 'w' <oz> logicalAnd "TeX"
bind 'w' <cs> sansSerif "TeX"
bind 'x' <o> xi "TeX"
bind 'x' <os> capXi "TeX"
bind 'x' <oz> multiply "TeX"
bind 'x' <cs> crossRef "TeX"
bind 'y' <o> psi "TeX"
bind 'y' <os> capPsi "TeX"
bind 'z' <o> zeta "TeX"
bind '\ ' <o> thin "TeX"
bind '\ ' <os> negThin "TeX"
bind '\ ' <oz> medium "TeX"
bind '\ ' <co> thick "TeX"
bind '\ ' <cs> quad "TeX"
bind '\ ' <cso> dblQuad "TeX"
bind ',' <o> lessOrEqual "TeX"
bind ',' <os> subset "TeX"
bind ',' <oz> subsetOrEqual "TeX"
bind ',' <co> subscript "TeX"
bind '.' <o> greaterOrEqual "TeX"
bind '.' <os> superset "TeX"
bind '.' <oz> supersetOrEqual "TeX"
bind '.' <co> superscript "TeX"
bind '/' <o> divide "TeX"
bind '/' <co> fraction "TeX"
bind '\;' <o> ellipsis "TeX"
bind '\;' <os> centerDots "TeX"
bind '\;' <oz> verticalDots "TeX"
bind '\;' <co> diagonalDots "TeX"
# apostrophe:
bind 0x27 <co> acuteAccent "TeX"
bind 0x27 <cs> quotes "TeX"
bind 0x27 <cso> dblQuotes "TeX"
bind '\[' <o> brackets "TeX"
bind '\[' <os> braces "TeX"
bind '\[' <co> bigBrackets "TeX"
bind '\[' <cso> bigBraces "TeX"
bind '\]' <o> displayStyle "TeX"
bind '\]' <os> textStyle "TeX"
bind '\]' <oz> scriptStyle "TeX"
bind '\]' <co> scriptscriptStyle "TeX"
bind '\]' <cso> bigLeftBrace "TeX"
bind '\' <o> backslash "TeX"
bind '\' <os> absoluteValue "TeX"
bind '\' <oz> setMinus "TeX"
bind '\' <co> bigAbsoluteValue "TeX"
bind '\' <cs> "oneParameter" "TeX"
bind '\' <cso> "twoParameters" "TeX"
bind '`' <co> graveAccent "TeX"
bind '`' <cso> tilde "TeX"
# Change to latexMath and latexDisplaymath, if desired:
bind '4' <co> texMath "TeX"
bind '4' <cso> texDisplaymath "TeX"
bind '5' <o> infinity "TeX"
bind '6' <o> sectionMark "TeX"
bind '6' <co> superscript "TeX"
bind '7' <o> paragraphMark "TeX"
bind '8' <o> bullet "TeX"
bind '8' <os> asterisk "TeX"
bind '8' <oz> centerDot "TeX"
bind '9' <os> parentheses "TeX"
bind '9' <co> bigParentheses "TeX"
bind '0' <oz> emptySet "TeX"
bind '-' <o> similar "TeX"
bind '-' <os> minusOrPlus "TeX"
bind '-' <oz> negation "TeX"
bind '-' <co> subscript "TeX"
bind '=' <o> notEqual "TeX"
bind '=' <os> plusOrMinus "TeX"
bind '=' <oz> approximate "TeX"
bind '=' <co> bar "TeX"
bind F5 <o> math "TeX"
bind F5 <os> displaymath "TeX"
bind F5 <oz> equation "TeX"
bind F6 <o> "myArray" "TeX"
bind F6 <os> "eqnarray" "TeX"
bind F6 <oz> "eqnarrayStar" "TeX"
bind F7 <o> "enumerate" "TeX"
bind F7 <os> "itemize" "TeX"
bind F7 <oz> "description" "TeX"
bind F8 <o> "tabular" "TeX"
bind F8 <os> tabbing "TeX"
bind F9 <o> figure "TeX"
bind F9 <os> table "TeX"
bind F9 <oz> slide "TeX"
bind F10 <o> verbatim "TeX"
bind F10 <os> quote "TeX"
bind F10 <oz> quotation "TeX"
bind F10 <co> verse "TeX"
bind F11 <o> "index" "TeX"
bind F11 <os> "bibliography" "TeX"
bind F12 <o> "general" "TeX"
# tab:
bind 0x30 nextTabStop "TeX"
bind 0x30 <s> previousTabStop "TeX"
} else {
# bind macros to option-control, use option as meta
bind 'a' <zo> alpha "TeX"
bind 'a' <zos> angle "TeX"
# bind 'a' <oz> forAll "TeX"
bind 'a' <zco> acuteAccent "TeX"
bind 'b' <zo> beta "TeX"
# bind 'b' <oz> box "TeX"
bind 'b' <zco> bar "TeX"
bind 'b' <zcs> bold "TeX"
bind 'c' <zo> chi "TeX"
bind 'c' <zco> check "TeX"
bind 'c' <zcs> citation "TeX"
bind 'c' <zcso> calligraphic "TeX"
bind 'd' <zo> delta "TeX"
bind 'd' <zos> capDelta "TeX"
# bind 'd' <oz> diamond "TeX"
bind 'd' <zco> dot "TeX"
bind 'd' <zcso> dblDot "TeX"
bind 'e' <zo> epsilon "TeX"
bind 'e' <zos> exists "TeX"
# bind 'e' <oz> varEpsilon "TeX"
bind 'e' <zcs> emphatic "TeX"
bind 'f' <zo> phi "TeX"
bind 'f' <zos> capPhi "TeX"
# bind 'f' <oz> varPhi "TeX"
bind 'f' <zco> fraction "TeX"
bind 'f' <zcs> footnote "TeX"
bind 'g' <zo> gamma "TeX"
bind 'g' <zos> capGamma "TeX"
# bind 'g' <oz> copyright "TeX"
bind 'g' <zco> graveAccent "TeX"
bind 'h' <zo> eta "TeX"
bind 'h' <zco> hat "TeX"
bind 'h' <zcs> smallCaps "TeX"
bind 'h' <zcso> wideHat "TeX"
bind 'i' <zo> iota "TeX"
# bind 'i' <oz> dotlessI "TeX"
bind 'i' <zco> integral "TeX"
bind 'i' <zcs> italic "TeX"
bind 'i' <zcso> mathItalic "TeX"
bind 'j' <zo> partial "TeX"
# bind 'j' <oz> dotlessJ "TeX"
bind 'k' <zo> kappa "TeX"
bind 'l' <zo> lambda "TeX"
bind 'l' <zos> capLambda "TeX"
# bind 'l' <oz> scriptL "TeX"
bind 'l' <zcs> label "TeX"
bind 'm' <zo> mu "TeX"
# bind 'm' <oz> mapsTo "TeX"
bind 'm' <zco> mbox "TeX"
bind 'm' <zcs> mbox "TeX"
bind 'n' <zo> nu "TeX"
bind 'n' <zos> aleph "TeX"
# bind 'n' <oz> intersection "TeX"
bind 'n' <zco> nthRoot "TeX"
bind 'n' <zcs> note "TeX"
bind 'o' <zo> circle "TeX"
bind 'o' <zos> bigCircle "TeX"
bind 'o' <zco> overline "TeX"
bind 'o' <zcso> overbrace "TeX"
bind 'p' <zo> pi "TeX"
bind 'p' <zos> capPi "TeX"
# bind 'p' <oz> varPi "TeX"
bind 'p' <zco> product "TeX"
bind 'p' <zcs> pageRef "TeX"
bind 'q' <zo> theta "TeX"
bind 'q' <zos> capTheta "TeX"
# bind 'q' <oz> varTheta "TeX"
bind 'r' <zo> rho "TeX"
# bind 'r' <oz> varRho "TeX"
bind 'r' <zco> squareRoot "TeX"
bind 'r' <zcs> roman "TeX"
bind 's' <zo> sigma "TeX"
bind 's' <zos> capSigma "TeX"
# bind 's' <oz> varSigma "TeX"
bind 's' <zco> sum "TeX"
bind 's' <zcs> slanted "TeX"
bind 't' <zo> tau "TeX"
bind 't' <zos> dagger "TeX"
# bind 't' <oz> triangle "TeX"
bind 't' <zco> tilde "TeX"
bind 't' <zcs> typewriter "TeX"
bind 't' <zcso> wideTilde "TeX"
bind 'u' <zo> upsilon "TeX"
bind 'u' <zos> capUpsilon "TeX"
# bind 'u' <oz> union "TeX"
bind 'u' <zco> underline "TeX"
bind 'u' <zcso> underbrace "TeX"
bind 'v' <zo> nabla "TeX"
# bind 'v' <oz> logicalOr "TeX"
bind 'v' <zco> vector "TeX"
bind 'w' <zo> omega "TeX"
bind 'w' <zos> capOmega "TeX"
# bind 'w' <oz> logicalAnd "TeX"
bind 'w' <zcs> sansSerif "TeX"
bind 'x' <zo> xi "TeX"
bind 'x' <zos> capXi "TeX"
# bind 'x' <oz> multiply "TeX"
bind 'x' <zcs> crossRef "TeX"
bind 'y' <zo> psi "TeX"
bind 'y' <zos> capPsi "TeX"
bind 'z' <zo> zeta "TeX"
bind '\ ' <zo> thin "TeX"
bind '\ ' <zos> negThin "TeX"
# bind '\ ' <oz> medium "TeX"
bind '\ ' <zco> thick "TeX"
bind '\ ' <zcs> quad "TeX"
bind '\ ' <zcso> dblQuad "TeX"
bind ',' <zo> lessOrEqual "TeX"
bind ',' <zos> subset "TeX"
# bind ',' <oz> subsetOrEqual "TeX"
bind ',' <zco> subscript "TeX"
bind '.' <zo> greaterOrEqual "TeX"
bind '.' <zos> superset "TeX"
# bind '.' <oz> supersetOrEqual "TeX"
bind '.' <zco> superscript "TeX"
bind '/' <zo> divide "TeX"
bind '/' <zco> fraction "TeX"
bind '\;' <zo> ellipsis "TeX"
bind '\;' <zos> centerDots "TeX"
# bind '\;' <oz> verticalDots "TeX"
bind '\;' <zco> diagonalDots "TeX"
# apostrophe:
bind 0x27 <zco> acuteAccent "TeX"
bind 0x27 <zcs> quotes "TeX"
bind 0x27 <zcso> dblQuotes "TeX"
bind '\[' <zo> brackets "TeX"
bind '\[' <zos> braces "TeX"
bind '\[' <zco> bigBrackets "TeX"
bind '\[' <zcso> bigBraces "TeX"
bind '\]' <zo> displayStyle "TeX"
bind '\]' <zos> textStyle "TeX"
# bind '\]' <oz> scriptStyle "TeX"
bind '\]' <zco> scriptscriptStyle "TeX"
bind '\]' <zcso> bigLeftBrace "TeX"
bind '\' <zo> backslash "TeX"
bind '\' <zos> absoluteValue "TeX"
# bind '\' <oz> setMinus "TeX"
bind '\' <zco> bigAbsoluteValue "TeX"
bind '\' <zcs> "oneParameter" "TeX"
bind '\' <zcso> "twoParameters" "TeX"
bind '`' <zco> graveAccent "TeX"
bind '`' <zcso> tilde "TeX"
# Change to latexMath and latexDisplaymath, if desired:
bind '4' <zco> texMath "TeX"
bind '4' <zcso> texDisplaymath "TeX"
bind '5' <zo> infinity "TeX"
bind '6' <zo> sectionMark "TeX"
bind '6' <zco> superscript "TeX"
bind '7' <zo> paragraphMark "TeX"
bind '8' <zo> bullet "TeX"
bind '8' <zos> asterisk "TeX"
# bind '8' <oz> centerDot "TeX"
bind '9' <zos> parentheses "TeX"
bind '9' <zco> bigParentheses "TeX"
# bind '0' <oz> emptySet "TeX"
bind '-' <zo> similar "TeX"
bind '-' <zos> minusOrPlus "TeX"
# bind '-' <oz> negation "TeX"
bind '-' <zco> subscript "TeX"
bind '=' <zo> notEqual "TeX"
bind '=' <zos> plusOrMinus "TeX"
# bind '=' <oz> approximate "TeX"
bind '=' <zco> bar "TeX"
bind F5 <zo> math "TeX"
bind F5 <zos> displaymath "TeX"
# bind F5 <oz> equation "TeX"
bind F6 <zo> "myArray" "TeX"
bind F6 <zos> "eqnarray" "TeX"
# bind F6 <oz> "eqnarrayStar" "TeX"
bind F7 <zo> "enumerate" "TeX"
bind F7 <zos> "itemize" "TeX"
# bind F7 <oz> "description" "TeX"
bind F8 <zo> "tabular" "TeX"
bind F8 <zos> tabbing "TeX"
bind F9 <zo> figure "TeX"
bind F9 <zos> table "TeX"
# bind F9 <oz> slide "TeX"
bind F10 <zo> verbatim "TeX"
bind F10 <zos> quote "TeX"
# bind F10 <oz> quotation "TeX"
bind F10 <zco> verse "TeX"
bind F11 <zo> "index" "TeX"
bind F11 <zos> "bibliography" "TeX"
bind F12 <zo> "general" "TeX"
# tab:
bind 0x30 nextTabStop "TeX"
bind 0x30 <s> previousTabStop "TeX"
}
#================================================================================
# Random nonsense
#================================================================================
proc nextSubSection {} {
set res [search -f 1 -r 1 -n {section\{} [nextLineStart [getPos]]]
if {[string length $res]} {
goto [lineStart [lindex $res 0]]
} else {
beep
}
}
bind 'n' <zs> nextSubSection "TeX"
proc prevSubSection {} {
set res [search -f 0 -r 1 -n {section\{} [lineStart [getPos]]]
if {[string length $res]} {
goto [lineStart [lindex $res 0]]
} else {
beep
}
}
bind 'p' <zs> prevSubSection "TeX"
proc nextSection {} {
set res [search -f 1 -r 1 -n {\\section\{} [nextLineStart [getPos]]]
if {[string length $res]} {
goto [lineStart [lindex $res 0]]
} else {
beep
}
}
bind 'n' <zsc> nextSection "TeX"
proc prevSection {} {
set res [search -f 0 -r 1 -n {\\section\{} [expr [lineStart [getPos]]-1]]
if {[string length $res]} {
goto [lineStart [lindex $res 0]]
} else {
beep
}
}
bind 'p' <zsc> prevSection "TeX"